package com.me.jingdongshop.ui.view;

/**
 * SwipeLayout的管理类：控制列表只打开一个SwipeLayout
 *
 * @author admin
 */
public class SwipeLayoutManager {

    // 单例
    private static SwipeLayoutManager mInstance = new SwipeLayoutManager();

    private SwipeLayoutManager(){
    }

    public static SwipeLayoutManager getInstance() {
        return mInstance;
    }

    /** 记录列表中打开的SwipeLayout */
    private SwipeLayout mOpenSwipeLayout;

    public SwipeLayout getOpenSwipeLayout() {
        return mOpenSwipeLayout;
    }

    /** 保存列表中打开的SwipeLayout */
    public void saveOpenSwipeLayout(SwipeLayout openSwipeLayout) {
        this.mOpenSwipeLayout = openSwipeLayout;
    }

    /** 列表是否已经打开了一个SwipeLayout */
    public boolean hasOpenSwipeLayout() {
        return mOpenSwipeLayout != null;
    }

    /** 清空列表中打开的SwipeLayout */
    public void clearSwipeLayout() {
        mOpenSwipeLayout = null;
    }

    /** 关闭列表中当前打开的SwipeLayout */
    public void closeOpenSwipeLayout() {
        if (mOpenSwipeLayout != null) {
            mOpenSwipeLayout.close();
            mOpenSwipeLayout = null;
        }
    }
}
